<?php

namespace app\admin\controller;

use think\Controller;
use app\common\model\Admin as AdminModel;
class Common extends Controller {

    protected function _initialize() {

//        $this->hasLogin();
        $this->init();
    }

    protected function hasLogin() {

//        $user = session('user');
//        $config_sys = cache('config_sys');
//        if ($user && $user['is_login']) {
////            if (intval($config_sys['system_more_login']) == 0) { //不允许同时登录
////                if (cache('session_id' . $user['user_uniid']) != session_id()) { //T掉
////                    session('user', null);
////                    $this->redirect('Admin/Index/login');
////                }
////            }
//        } else {
//            if (ACTION_NAME != 'login') {
//                $this->redirect('Admin/Index/login');
//            }
//        }
   }

    protected function init() {
        $admin = AdminModel::get(session('user_id'));
        $this->assign('user', $admin);
        $menu = config('menu.adminmenu');

      $this->assign('menu', $menu);
//        $this->assign('totalaward', $user->awards()->alias('a')->join('ycyp_award b', 'a.cash_flow_id = b.cash_flow_id')->where('b.award_type','<>','1')->sum('cash_value'));
//        $this->assign('totalrespond', $user->awards()->alias('a')->join('ycyp_award b', 'a.cash_flow_id = b.cash_flow_id')->where('b.award_type','1')->sum('cash_value'));
//        $this->assign('frozenaward', $user->awards()->alias('a')->join('ycyp_award b', 'a.cash_flow_id = b.cash_flow_id')->where('b.award_type','<>','1')->where('a.cash_flow_status','0')->sum('cash_value'));
//        $this->assign('nowmoneycash', $user->money_cash);

    }

    protected function validate_($data, $rule) {
        if (($validateResult = $this->validate($data, $rule)) !== true) {
            throw new \Exception($validateResult);
        }
    }

    protected function e($message) {
        throw new \Exception($message);
    }



}
